using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Apache.Cassandra;


namespace Cassandraemon
{


	public static class CounterSuperColumnExtensions
	{
		public static CounterSuperColumn SetName(this CounterSuperColumn source, object name)
		{
			source.Name = name.ToCassandraByte();
			return source;
		}
		
		public static CounterSuperColumn SetColumn(this CounterSuperColumn source, CounterColumn column)
		{
			source.Columns = new List<CounterColumn>();
			source.Columns.Add(column);
			return source;
		}
		
		public static CounterSuperColumn SetColumn(this CounterSuperColumn source, object name, long value)
		{
			return source.SetColumn(new CounterColumn().SetNameValue(name, value));
		}
		
		
		public static CounterSuperColumn SetColumnList(this CounterSuperColumn source, IEnumerable<CounterColumn> columnList)
		{
			source.Columns = new List<CounterColumn>();
			source.Columns.AddRange(columnList);
			return source;
		}
		
		
		public static CounterSuperColumn AddColumn(this CounterSuperColumn source, CounterColumn column)
		{
			if(source.Columns == null) source.Columns = new List<CounterColumn>();
			source.Columns.Add(column);
			return source;
		}
		
		public static CounterSuperColumn AddColumn(this CounterSuperColumn source, object name, long value)
		{
			return source.AddColumn(new CounterColumn().SetNameValue(name, value));
		}
		
		
		public static CounterSuperColumn AddColumnList(this CounterSuperColumn source, IEnumerable<CounterColumn> columnList)
		{
			if(source.Columns == null) source.Columns = new List<CounterColumn>();
			source.Columns.AddRange(columnList);
			return source;
		}
		
		
		public static List<CounterSuperColumn> Add(this ICollection<CounterSuperColumn> source, object name, CounterColumn column)
		{
			source.Add(new CounterSuperColumn().SetName(name).SetColumn(column));
			return source.ToList();
		}
		
		public static List<CounterSuperColumn> Add(this ICollection<CounterSuperColumn> source, object name, object columnName, long columnValue)
		{
			return source.Add(name, new CounterColumn().SetNameValue(columnName, columnValue));;
		}
		
		public static List<CounterSuperColumn> Add(this ICollection<CounterSuperColumn> source, object name, IEnumerable<CounterColumn> columnList)
		{
			source.Add(new CounterSuperColumn().SetName(name).SetColumnList(columnList));
			return source.ToList();
		}
	}
}
